package com.congwulin.wechat.RabbitMQ;

import com.congwulin.wechat.entity.UserForWeChat;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class HelloSender {

    @Autowired
    private AmqpTemplate template;

    public void send() {
        String context = "hello " + new Date();
        System.out.println("Sender : " + context);
        this.template.convertAndSend("hello", context);
    }

    public void sendUser(UserForWeChat user){
        String context = "hello name:" + user.getName() + " age: " + user.getAge() + " id: "+ user.getId();
        System.out.println("Sender : " + context);
        this.template.convertAndSend("hello",user);
    }
}
